layui.use(['table','func'], function(){
    var $ = layui.jquery;
    var table = layui.table;
    var laydate = layui.laydate;
    var func = layui.func;
    var form = layui.form;


    /**
     * 管理
     */
    var StudentIdManagement = {
        tableId: "studentIdManagement"
    };

    /**
     * 初始化表格的列
     */
    StudentIdManagement.initColumn = function () {
        return [[
            {type: 'checkbox'},
            {field: 'student_id', sort: true, title: '学号ID'},
            {field: 'student_number', sort: true, title: '学号'},
            {field: 'name', sort: true, title: '名称'},
            {field: 'sex', sort: true, title: '性别'},
            {field: 'grade', sort: true, title: '年级'},
            {field: 'in_campus', sort: true, title: '所在校区'},
            {field: 'college', sort: true, title: '学院'},
            {field: 'professional_no', sort: true, title: '专业号'},
            {field: 'major_name', sort: true, title: '专业名称'},
            {field: 'class_grade', sort: true, title: '班级'}
        ]];
    };

// 渲染表格
    var tableResult = table.render({
        elem: '#' + StudentIdManagement.tableId,
        url: '/studentIdManagement/list',
        page: true,
        height: "full-158",
        cellMinWidth: 100,
        cols: StudentIdManagement.initColumn()
    });

    /**
     * 点击查询按钮
     */
    StudentIdManagement.search = function () {
        var queryData = {};

        //姓名
        queryData['name'] = $('#name').val();
        //性别
        queryData['sex'] = $('#sex').val();
        //校区
        queryData['inCampus']= $('#inCampus').val();

        table.reload(StudentIdManagement.tableId, {
            where: queryData, page: {curr: 1}
        });
    };
// 搜索按钮点击事件
    $('#btnSearch').click(function () {
        StudentIdManagement.search();
    });


    /**
     * 重置搜索条件
     */
    $('#reset').click(function () {
        $('#name').val("");
        $('#sex').val("");
        $('#inCampus').val("");
        form.render('select');
        StudentIdManagement.search();
    })


    // 工具条点击事件
    table.on('tool(' + StudentIdManagement.tableId + ')', function (obj) {
        var data = obj.data;
        var layEvent = obj.event;

        if(layEvent == "edit"){
            StudentIdManagement.edit(data);
        }

    });
});